<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>家具订单管理系统</title>
  <style>
    body {
      margin: 0;
      padding: 0;
    }
  </style>
</head>
<body>
  <div id="app">
    <div v-if="loading" class="loading-container">
      <div style="text-align: center; padding: 50px;">
        <div style="font-size: 18px;">加载中...</div>
      </div>
    </div>
    <div v-else>
      <div class="header">
        <div class="container">
          <h1>🛋️ 家具订单管理系统</h1>
          <p>查看所有订单信息 | 导出数据</p>
        </div>
      </div>

      <div class="container">
        <!-- 操作栏 -->
        <div class="action-bar">
          <div class="stats-section">
            <el-tag type="info" size="large">共 {{ orders.length }} 条订单</el-tag>
            <el-tag type="success" size="large">
              总金额: ¥{{ totalMoney.toFixed(2) }}
            </el-tag>
          </div>
          <el-button type="success" @click="exportOrders">📥 导出Excel</el-button>
        </div>

        <!-- 订单列表 -->
        <div class="content-card">
          <el-table
            :data="orders"
            style="width: 100%"
            stripe
            border
            :default-sort="{ prop: 'orderDate', order: 'descending' }"
          >
            <el-table-column prop="orderDate" label="下单日期" width="120" sortable></el-table-column>
            <el-table-column prop="orderNumber" label="单号" width="150" sortable></el-table-column>
            <el-table-column prop="style" label="款式" min-width="180"></el-table-column>
            <el-table-column prop="size" label="尺寸" width="140"></el-table-column>
            <el-table-column prop="quantity" label="数量" width="80" align="center"></el-table-column>
            <el-table-column prop="unitPrice" label="单价" width="100" align="right">
              <template #default="scope">
                ¥{{ scope.row.unitPrice.toFixed(2) }}
              </template>
            </el-table-column>
            <el-table-column prop="totalAmount" label="总额" width="120" align="right" sortable>
              <template #default="scope">
                <span class="amount-cell">¥{{ scope.row.totalAmount.toFixed(2) }}</span>
              </template>
            </el-table-column>
          </el-table>

          <!-- 空状态 -->
          <el-empty v-if="orders.length === 0" description="暂无订单数据"></el-empty>
        </div>

        <!-- 底部提示 -->
        <div style="text-align: center; margin-top: 20px; color: #909399; font-size: 14px;">
          <p>此页面为只读模式，如需编辑订单请访问 <a href="/admin.html" style="color: #409EFF;">后端管理页面</a></p>
        </div>
      </div>
    </div>
  </div>

  <script type="module" src="/src/main.js"></script>
</body>
</html>
